package com.enterprise.dao.impl;

import com.enterprise.dao.BaseDao;
import com.enterprise.dao.CaseDao;
import com.enterprise.entity.Case;
import com.enterprise.entity.page.PageModel;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository("caseDao")
public class CaseDaoImpl implements CaseDao{

	@Resource
	private BaseDao dao;
	
	public void setDao(BaseDao dao) {
		this.dao = dao;
	}
	
	@Override
	public int insert(Case e) {
		// TODO Auto-generated method stub
		return dao.insert("case.insert", e);
	}

	@Override
	public int delete(Case e) {
		// TODO Auto-generated method stub
		return dao.delete("case.delete", e);
	}

	@Override
	public int update(Case e) {
		// TODO Auto-generated method stub
		return dao.update("case.update", e);
	}

	@Override
	public Case selectOne(Case e) {
		// TODO Auto-generated method stub
		return (Case) dao.selectOne("case.selectOne", e);
	}

	@Override
	public PageModel selectPageList(Case e) {
		// TODO Auto-generated method stub
		return dao.selectPageList("case.selectPageList", "case.selectPageCount", e);
	}

	@Override
	public List<Case> selectList(Case e) {
		// TODO Auto-generated method stub
		return dao.selectList("case.selectList", e);
	}

	@Override
	public int deleteById(int id) {
		// TODO Auto-generated method stub
		return dao.delete("case.deleteById", id);
	}

	@Override
	public Case selectById(int id) {
		// TODO Auto-generated method stub
		return (Case) dao.selectOne("case.selectById", id);
	}

	@Override
	public PageModel selectPage(Case e) {
		PageModel pageModel = new PageModel();
		pageModel.setOffset(e.getOffset());
		pageModel.setPageSize(e.getPageSize());
		e.setOffset((e.getOffset()-1) * e.getPageSize());
		return dao.selectPage("case.selectPageList", "case.selectPageCount", e,pageModel);
	}

}
